package cn.fl.project.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.cmm.base.framework.logger.eum.LogExceptionEnum;
import cn.cmm.base.framework.logger.eum.LogOperEnum;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.fl.project.constant.PrjBscInfoConstant;
import fl.constant.facade.framework.constant.BusinessIdConstant;
import fl.spl.facade.framework.constant.SplSystemConstant;
import fl.spl.facade.lnkcomp.condition.PrjLnkCompRlPsnQC;
import fl.spl.facade.lnkcomp.constant.PrjLnkCompRelInfoConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.KeyValueVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.mid.core.framework.page.Pager;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.project.service.IPrjLnkCompRlPsnService;
import cn.fl.project.service.IPrjLnkCompService;
import cn.fl.project.vo.PrjLnkCompRlPsnVO;
import cn.fl.system.constant.SysLogConstant;
import cn.fl.system.service.ISysDictionaryService;
import fl.riskctrl.facade.riskctrl.dto.DataResultDTO;
import net.sf.json.JSONArray;

/**
 * @Description: 挂靠公司关联人员信息表 控制层
 */
@Controller
@RequestMapping("/project/prjLnkCompRlPsn")
public class PrjLnkCompRlPsnController extends BaseController {

	/**
	 * PrjLnkCompRlPsn 服务层BEAN
	 */
	@Autowired
	private IPrjLnkCompRlPsnService prjLnkCompRlPsnService;
	
	@Autowired
	private IPrjLnkCompService prjLnkCompService ;
	@Autowired
	private ISysDictionaryService sysDictionaryService ;

	/**
	 * 到列表页面
	 */
	@RequestMapping(value = "/toListPage.do", method = { RequestMethod.GET})
	public ModelAndView toListPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("project/prjLnkCompRlPsn/list");
		return view;
	}

	/**
	 * 到修改页面
	 */
	@RequestMapping(value = "/toModifyPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toModifyPage(HttpServletRequest request, HttpServletResponse response) {
		String id = request.getParameter("id");
		ModelAndView view = new ModelAndView("project/prjLnkCompRlPsn/modify");
		view.addObject("id", id);
		BaseLogUtils.newWebLogger("挂靠公司关联人员信息，跳转到修改页面").setLogOperType(LogOperEnum.REQ)
				.setSysCd(CurrentThreadContext.getCurrentSysCd())
				.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
				.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
				.setWarning(false)
				.setKeys("id", id)
				.info();
		return view;
	}

	/**
	 * 初始化列表
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/initList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object initList(HttpServletRequest request, HttpServletResponse response) {
		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		String prjLnkCompId = request.getParameter("prjLnkCompId");
		String isMaskStr = request.getParameter("isMask");
		int isMask = 0 ;
		String roleisEncrypt = this.sysDictionaryService.getRoleisEncrypt();
		BaseLogUtils.newWebLogger("根据角色查询是否需要掩码").setLogOperType(LogOperEnum.REQ)
				.setSysCd(CurrentThreadContext.getCurrentSysCd())
				.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
				.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
				.setWarning(false)
				.setKeys("roleisEncrypt", roleisEncrypt)
				.info();
		if(StringUtils.isNotEmpty(isMaskStr) && BaseConstant.IS_YESNO_YES_STR.equals(isMaskStr) 
				&& BaseConstant.IS_YESNO_YES_STR.equals(roleisEncrypt)){
			isMask = 1 ;
		}
		Pager page = new Pager();
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.parseInt(currentPage));
		}

		if (StringUtils.isNotEmpty(pageSize)) {
			page.setEveryPage(Integer.MAX_VALUE);
		}

		PrjLnkCompRlPsnQC qc = new PrjLnkCompRlPsnQC();
		if (StringUtils.isNotEmpty(prjLnkCompId)) {
			qc.setPrjLnkCompId(Long.valueOf(prjLnkCompId));
		}else{
			List<PrjLnkCompRlPsnVO>  prjLnkCompRlPsnVOS= new ArrayList<>() ;
			List<KeyValueVO> prjLnkCompRlRsnTypList = prjLnkCompService.getPrjLnkCompRlRsnTypList();
			List<KeyValueVO> certTypCdList = prjLnkCompService.getCertTypCdList();
			String defCodNm = "";
			for (KeyValueVO keyValueVO : certTypCdList) {
				if (keyValueVO.getKey().equals(PrjLnkCompRelInfoConstant.CODE_CERT_TYP_DEF_CD)) {
					defCodNm = keyValueVO.getValue();
				}
			}
			if (CollectionUtils.isNotEmpty(prjLnkCompRlRsnTypList)) {
				for (KeyValueVO keyValueVO : prjLnkCompRlRsnTypList) {
					if (keyValueVO.getKey().equals(PrjLnkCompRelInfoConstant.CODE_RL_TYP_CD_2)) {
						PrjLnkCompRlPsnVO rlPsnVO = new PrjLnkCompRlPsnVO();
						rlPsnVO.setRlTypCd(keyValueVO.getKey());
						rlPsnVO.setRlTypCdNm(keyValueVO.getValue());
						rlPsnVO.setCertTypCd(PrjLnkCompRelInfoConstant.CODE_CERT_TYP_DEF_CD);
						rlPsnVO.setCertTypCdNm(defCodNm);
						rlPsnVO.setIsSysDef(BaseConstant.IS_YESNO_YES);
						rlPsnVO.setIsVerify(BaseConstant.IS_YESNO_YES);
						prjLnkCompRlPsnVOS.add(rlPsnVO);
					}
				}
			}
			ListPageVO<PrjLnkCompRlPsnVO> listPage = new ListPageVO<PrjLnkCompRlPsnVO>(prjLnkCompRlPsnVOS, 1);
			return listPage ;
		}
		page.setCondition(qc);

		Pager pager = this.prjLnkCompRlPsnService.searchListPage(page,isMask);
		
		List<PrjLnkCompRlPsnVO> list = (List<PrjLnkCompRlPsnVO>) pager.getResultList();
		List<KeyValueVO> rlPsnTypList = prjLnkCompService.getPrjLnkCompRlRsnTypList();
		BaseLogUtils.newWebLogger("联系人类型").setLogOperType(LogOperEnum.REQ)
				.setSysCd(CurrentThreadContext.getCurrentSysCd())
				.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
				.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
				.setWarning(false)
				.setKeys("rlPsnTypList", JSON.toJSONString(rlPsnTypList))
				.info();
		List<KeyValueVO> certTypCdList = prjLnkCompService.getCertTypCdList();
		BaseLogUtils.newWebLogger("联系人证件类型").setLogOperType(LogOperEnum.REQ)
				.setSysCd(CurrentThreadContext.getCurrentSysCd())
				.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
				.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
				.setWarning(false)
				.setKeys("certTypCdList", JSON.toJSONString(certTypCdList))
				.info();
		Map<String,String> certTypMap = new HashMap<>();
		for (KeyValueVO keyValueVO : certTypCdList) {
			certTypMap.put(keyValueVO.getKey(), keyValueVO.getValue());
		}
		Map<String,String> rlPsnTypMap = new HashMap<>();
		for (KeyValueVO keyValueVO : rlPsnTypList) {
			rlPsnTypMap.put(keyValueVO.getKey(),keyValueVO.getValue());
		}
		for (PrjLnkCompRlPsnVO vo : list) {
			if(certTypMap.containsKey(vo.getCertTypCd())){
				vo.setCertTypCdNm(certTypMap.get(vo.getCertTypCd()));
			}
			//人员类型
			if(rlPsnTypMap.containsKey(vo.getRlTypCd())){
				vo.setRlTypCdNm(rlPsnTypMap.get(vo.getRlTypCd()));
			}
		}
		ListPageVO<PrjLnkCompRlPsnVO> listPage = new ListPageVO<PrjLnkCompRlPsnVO>(list, pager.getTotalCount());
		BaseLogUtils.newWebLogger("挂靠公司关联人员信息查询数据完成").setLogOperType(LogOperEnum.REQ)
				.setSysCd(CurrentThreadContext.getCurrentSysCd())
				.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
				.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
				.setWarning(false)
				.setKeys("DATA", JSONObject.toJSONString(page))
				.info();
		return listPage;
	}

	/**
	 * 删除数据
	 */
	@RequestMapping(value = "/removeById.do", method = {RequestMethod.POST })
	@ResponseBody
	public DataResultVO removeById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_DELETE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.newWebLogger("删除挂靠公司关联人员信息,id为空").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
					.setWarning(false)
					.warn(LogExceptionEnum.COMMON_CODE_0002);
			return result;
		}
		try {
			this.prjLnkCompRlPsnService.removeById(Long.valueOf(id));
			BaseLogUtils.newWebLogger("删除数据").setLogOperType(LogOperEnum.RESP)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
					.setWarning(false)
					.setKeys("result", JSON.toJSONString(result))
					.info();
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.newWebLogger("删除数据失败,业务异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.warn(LogExceptionEnum.COMMON_CODE_0001);
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.newWebLogger("删除数据失败,系统异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.error(LogExceptionEnum.COMMON_CODE_0099);
		}

		return result;
	}

	/**
	 * 得到一条记录
	 * 
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getById.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object getById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.newWebLogger("获取挂靠公司关联人员信息,id为空").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
					.setWarning(false)
					.warn(LogExceptionEnum.COMMON_CODE_0002);
			return result;
		}
		
		try {
			PrjLnkCompRlPsnVO vo = this.prjLnkCompRlPsnService.selectById(Long.valueOf(id));
			if(null == vo){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
				BaseLogUtils.newWebLogger("获取挂靠公司关联人员信息数据不存在!").setLogOperType(LogOperEnum.RESP)
						.setSysCd(CurrentThreadContext.getCurrentSysCd())
						.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
						.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
						.setWarning(false)
						.warn(LogExceptionEnum.COMMON_CODE_0002);
			}
			result.setData(vo);
			BaseLogUtils.newWebLogger("获取挂靠公司关联人员信息").setLogOperType(LogOperEnum.RESP)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
					.setWarning(false)
					.setKeys("result", JSON.toJSONString(result))
					.info();
		}catch(BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.newWebLogger("获取挂靠公司关联人员信息失败,业务异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.warn(LogExceptionEnum.COMMON_CODE_0001);
		}catch(Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.newWebLogger("获取挂靠公司关联人员信息,系统异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.error(LogExceptionEnum.COMMON_CODE_0099);
		}
		return result;
	}

	/**
	 * 新增挂靠公司关联人员信息
	 */
	@RequestMapping(value = "/add.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object add(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String name = request.getParameter("name");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
		PrjLnkCompRlPsnVO entity = null;
		try {
			entity = new PrjLnkCompRlPsnVO();
			//TODO ADD PARAM
			Long id = this.prjLnkCompRlPsnService.add(entity);
			result.setData(id);
			BaseLogUtils.newWebLogger("新增挂靠公司关联人员信息").setLogOperType(LogOperEnum.RESP)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
					.setWarning(false)
					.setKeys("entity", JSON.toJSONString(entity))
					.info();
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.newWebLogger("新增挂靠公司关联人员信息失败,业务异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.warn(LogExceptionEnum.COMMON_CODE_0001);
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.newWebLogger("新增挂靠公司关联人员信息失败,系统异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.error(LogExceptionEnum.COMMON_CODE_0099);
		}

		return result;
	}

	/**
	 * 修改挂靠公司关联人员信息
	 */
	@RequestMapping(value = "/modify.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object modify(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		String name = request.getParameter("name");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.newWebLogger("修改挂靠公司关联人员信息,id为空").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
					.setWarning(false)
					.warn(LogExceptionEnum.COMMON_CODE_0002);
			return result;
		}
		PrjLnkCompRlPsnVO entity = null;
		try {
			entity = new PrjLnkCompRlPsnVO();
			entity.setId(Long.valueOf(id));
			//entity.setName(name);
			//TODO ADD PARAM
			boolean success = this.prjLnkCompRlPsnService.modify(entity);
			if(!success){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
				BaseLogUtils.newWebLogger("修改挂靠公司关联人员信息失败!").setLogOperType(LogOperEnum.RESP)
						.setSysCd(CurrentThreadContext.getCurrentSysCd())
						.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
						.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
						.setWarning(false)
						.warn(LogExceptionEnum.COMMON_CODE_0002);
			}
			BaseLogUtils.newWebLogger("修改挂靠公司关联人员信息成功!").setLogOperType(LogOperEnum.RESP)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
					.setWarning(false)
					.setKeys("result", JSON.toJSONString(result))
					.info();
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.newWebLogger("修改挂靠公司关联人员信息失败,业务异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.warn(LogExceptionEnum.COMMON_CODE_0001);
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.newWebLogger("修改挂靠公司关联人员信息失败,系统异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.error(LogExceptionEnum.COMMON_CODE_0099);
		}
		return result;
	}
	/**
	 * 删除挂靠公司关联人员信息
	 */
	@RequestMapping(value = "/removeByIds.do", method = {RequestMethod.POST })
	@ResponseBody
	public DataResultVO removeByIds(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String ids = request.getParameter("ids");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_DELETE_SUCC);
		if(StringUtils.isEmpty(ids)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.newWebLogger("删除挂靠公司关联人员信息,ID集合为空!").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
					.setWarning(false)
					.warn(LogExceptionEnum.COMMON_CODE_0001);
			return result;
		}
		List<Long> idList = new ArrayList<Long>();
		JSONArray idsArray = JSONArray.fromObject(ids);
		for (Object object : idsArray) {
			idList.add(Long.valueOf(object.toString()));
		}
		try {
			this.prjLnkCompRlPsnService.removeByIds(idList);
			BaseLogUtils.newWebLogger("删除挂靠公司关联人员信息").setLogOperType(LogOperEnum.RESP)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
					.setWarning(false)
					.setKeys("ids", ids)
					.info();
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.newWebLogger("删除挂靠公司关联人员信息,业务异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.warn(LogExceptionEnum.COMMON_CODE_0001);
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.newWebLogger("删除挂靠公司关联人员信息,系统异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.error(LogExceptionEnum.COMMON_CODE_0099);
		}
		result.setSuccess(BaseConstant.IS_YESNO_YES);
		return result;
	}
	
	@RequestMapping(value = "/checkRlPsn.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object checkRlPsnMessage(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES,SysLogConstant.LOG_CMM_UPDATE_SUCC);
		String type = request.getParameter("type");//校验类型
		String rlId = request.getParameter("dataId");//联系人ID
		String rlNm = request.getParameter("rlNm");//联系人姓名
		String certNo = request.getParameter("certNo");//联系人身份证号
		String tel = request.getParameter("tel");//联系人电话
		String compId = request.getParameter("compId");//所属供应商ID
		String rlTypCd = request.getParameter("rlTpyCd");//联系人类型
		String applyPsnId = request.getParameter("applyPsnId");
		String applyId = request.getParameter("applyId");
		if(StringUtils.isEmpty(type)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("参数不完整");
			return result ;
		}
		if(StringUtils.isEmpty(certNo)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("联系人身份证号不能为空");
			return result ;
		}
		if(StringUtils.isEmpty(rlNm)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("联系姓名不能为空");
			return result ;
		}
		if("verify".equals(type)){
			if(StringUtils.isEmpty(compId)){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo("挂靠公司ID不能为空");
				return result ;
			}
		}else{
			if(StringUtils.isEmpty(tel)){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo("手机号不能为空");
				return result ;
			}
		}
		if(StringUtils.isEmpty(rlId) && StringUtils.isEmpty(applyPsnId)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("主键ID不能为空");
			return result ;
		}
		HashMap<String, String> dataMap = new HashMap<>();
		dataMap.put("type", type);
		dataMap.put("rlId", rlId);
		dataMap.put("rlNm", rlNm);
		dataMap.put("tel", tel);
		dataMap.put("compId", compId);
		dataMap.put("certNo", certNo);
		dataMap.put("rlTypCd", rlTypCd);
		dataMap.put("applyId",applyId);
		if(StringUtils.isEmpty(applyPsnId) && applyPsnId == "null" ){
			dataMap.put("applyPsnId", "");
		}else{
			dataMap.put("applyPsnId", applyPsnId);
		}
		BaseLogUtils.newWebLogger("主要人员数据信息").setLogOperType(LogOperEnum.REQ)
				.setSysCd(CurrentThreadContext.getCurrentSysCd())
				.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
				.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
				.setWarning(false)
				.setKeys("dataMap", JSON.toJSONString(dataMap))
				.info();
		DataResultDTO checkRlPsn = this.prjLnkCompRlPsnService.checkRlPsnVerify(dataMap);
		BaseLogUtils.newWebLogger("主要人员三要素校验查询结果").setLogOperType(LogOperEnum.RESP)
				.setSysCd(CurrentThreadContext.getCurrentSysCd())
				.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
				.setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
				.setWarning(false)
				.setKeys("checkRlPsn", JSON.toJSONString(checkRlPsn))
				.info();
		result.setSuccess(checkRlPsn.getSuccess());
		result.setInfo(checkRlPsn.getInfo());
		result.setData(checkRlPsn.getData());
		return result ;
	}


}

